'''
Created on Apr 17, 2010

@author: darkelf
'''

class BHObject(object):
    
    def __init__(self):
        object.__init__(self)
    
    def get_html(self):
        return ""

class BasicHtmlText(BHObject):
    
    def __init__(self):
        BHObject.__init__(self)
        self.text_content = ''
    
    def set_content(self, content):
        content = content.replace("\n","").replace("\t","").replace("\r","")
        self.text_content = content
    
    def get_html(self):
        return self.text_content

class BasicHtmlObject(BHObject):
    
    def __init__(self, name=''):
        BHObject.__init__(self)
        self.element_name = name
        self.childs = []
        self.attributes = {}
        
    def set_id(self, id):
        self.attributes["id"] = id
        
    def get_html(self):
        html = "<" + self.element_name + " "
        for attr in self.attributes:
            html+= attr + "=\"" + self.attributes[attr] + "\" "
        
        if len(self.childs) > 0:
            html+= ">"
            for child in self.childs:
                html+= child.get_html()
            html+= "</" + self.element_name + ">"
        else:
            html+= "/>"
        
        return html
    
class BasicJavaScript(BasicHtmlObject):
    
    def __init__(self):
        BasicHtmlObject.__init__(self, "script")

class BasicHtmlPage(BasicHtmlObject):
    
    def __init__(self):
        BasicHtmlObject.__init__(self, "html")
    
class BasicHtmlBody(BasicHtmlObject):
    
    def __init__(self):
        BasicHtmlObject.__init__(self, "body")
        
    def set_onload(self, onload):
        self.attributes["onload"] = onload
        
class BasicHtmlHead(BasicHtmlObject):
    
    def __init__(self):
        BasicHtmlObject.__init__(self, "head")
        
class BasicHtmlHeadTitle(BasicHtmlObject):
    
    def __init__(self):
        BasicHtmlObject.__init__(self, "title")
    
class HtmlImage(BasicHtmlObject):
    
    def __init__(self):
        BasicHtmlObject.__init__(self, "img")        
    
    def set_src(self, src):
        self.attributes["src"] = src
        
    def get_src(self):
        return self.attributes["src"]
    
    def set_width(self, width):
        self.attributes["width"] = width
    
    def get_width(self):
        return self.attributes["width"]
    
    def set_height(self, height):
        self.attributes["height"] = height
    
    def get_height(self):
        return self.attributes["height"]

class HtmlFont(BasicHtmlObject):
    
    def __init__(self):
        BasicHtmlObject.__init__(self, "font")        
    
    def set_color(self, color):
        self.attributes["color"] = color
        
    def get_color(self):
        return self.attributes["color"]

class HtmlDiv(BasicHtmlObject):
    
    def __init__(self):
        BasicHtmlObject.__init__(self, "div")
    
    def set_width(self, width):
        self.attributes["width"] = width
    
    def get_width(self):
        return self.attributes["width"]
    
    def set_height(self, height):
        self.attributes["height"] = height
    
    def get_height(self):
        return self.attributes["height"]

class HtmlTable(BasicHtmlObject):
    
    def __init__(self):
        BasicHtmlObject.__init__(self, "table")
    
    def set_width(self, width):
        self.attributes["width"] = width
    
    def get_width(self):
        return self.attributes["width"]
    
    def set_height(self, height):
        self.attributes["height"] = height
    
    def get_height(self):
        return self.attributes["height"]
    
    def set_cellpadding(self, cellpadding):
        self.attributes["cellpadding"] = cellpadding
    
    def get_cellpadding(self):
        return self.attributes["cellpadding"]
    
    def set_cellspacing(self, cellspacing):
        self.attributes["cellspacing"] = cellspacing
        
    def get_cellspacing(self):
        return self.attributes["cellspacing"]

class HtmlTableRow(BasicHtmlObject):
    
    def __init__(self):
        BasicHtmlObject.__init__(self, "tr")
        
    def set_width(self, width):
        self.attributes["width"] = width
    
    def get_width(self):
        return self.attributes["width"]
    
    def set_height(self, height):
        self.attributes["height"] = height
    
    def get_height(self):
        return self.attributes["height"]

class HtmlTableData(BasicHtmlObject):
    
    def __init__(self):
        BasicHtmlObject.__init__(self, "td")
    
    def set_width(self, width):
        self.attributes["width"] = width
    
    def get_width(self):
        return self.attributes["width"]
    
    def set_height(self, height):
        self.attributes["height"] = height
    
    def get_height(self):
        return self.attributes["height"]